(function(){
  var date = new ruiDatepicker().init('#birth-date')
  var paydate = new ruiDatepicker().init('#pay-date')
  $('#select-phone').submit(function(){
    var reg = /^1\d{10}$/
    var checkPhone = !!($(this).find('[name="phone"]').val().match(reg))
    if(!checkPhone) {
      toast('请输入正确的手机号码')
    }
    return checkPhone
  })

  $('#select-name').submit(function(){
    var nameReg = /^[\u4e00-\u9fa5]{2,4}$/;
    var checkName = !!($(this).find('[name="name"]').val().match(nameReg))
    var birth = $('#birth-date').val()
    var pay = $('#pay-date').val()
    if(!checkName) {
      toast('请输入正确的名字')
    }else if(!birth){
      toast('请输入出生日期')
    }else if(!pay){
      toast('请输入付款日期')
    }
    
    return checkName && !!birth && !!pay
  })

  $('#select-id').submit(function(){
    var idReg = /^\d{11}$/
    var checkId = !!($(this).find('[name="order-id"]').val().match(idReg))
    if(!checkId){
      toast('请输入正确的订单号')
    }
    return checkId
  })
}())